//
//  AppDelegate.m
//  MyStock
//
//  Created by 刘翔 on 2024/8/14.
//

#import "AppDelegate.h"
#import "AppService.h"
#import "MainTabBarController.h"
#import "HomeVC.h"
#import "TokenVC.h"
#import "BaseNavigationController.h"
#import <ZFPlayer/ZFLandscapeRotationManager.h>

@interface AppDelegate ()

@end

@implementation AppDelegate


- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
    // Override point for customization after application launch.
    
    //设置网络请求头
//    NSString *user_token = [NSString stringWithFormat:@"%@",[LoginManger sharedManager].currentLoginModel.token];
//    NSDictionary *headerdic = @{@"user_token":user_token};
//    [BANetManager sharedBANetManager].httpHeaderFieldDictionary = headerdic;
    
    BANetManagerShare.isOpenLog = NO;

        
    
    self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
    UIViewController *rootVC;
    NSString *token = [NSString stringWithFormat:@"%@",[LxUserDefaults objectForKey:LXToken]];
    if (token.length == 0 || [token isEqualToString:@"(null)"]) {
        //未登录
        rootVC = [[BaseNavigationController alloc] initWithRootViewController:[TokenVC new]];
    }else{
              
        [[BANetManager sharedBANetManager] setHttpHeaderFieldDictionary:@{@"token":token}];
        rootVC = [[MainTabBarController alloc] init];
       
    }
    
    self.window.rootViewController = rootVC;
    [self.window makeKeyAndVisible];

    [[AppService shareInstance] registerAppService:application didFinishLaunchingWithOptions:launchOptions];
    
    return YES;
}

/// 在这里写支持的旋转方向，为了防止横屏方向，应用启动时候界面变为横屏模式
- (UIInterfaceOrientationMask)application:(UIApplication *)application supportedInterfaceOrientationsForWindow:(UIWindow *)window {
    ZFInterfaceOrientationMask orientationMask = [ZFLandscapeRotationManager supportedInterfaceOrientationsForWindow:window];
    if (orientationMask != ZFInterfaceOrientationMaskUnknow) {
        return (UIInterfaceOrientationMask)orientationMask;
    }
    /// 这里是非播放器VC支持的方向
    return UIInterfaceOrientationMaskPortrait;
}




@end
